import instance from '../../utils/request'

export function findOutApply(params) {
    return instance.get("/crm/refacoutapply/find", {params: params});
}

/**获取当前登录的用户名
 *
 * @returns {*}
 */
export function getUserName() {
    return instance.get("/crm/refacoutapply/getUser");
}

/**
 * 根据id获得对应的出库申请单
 * @param id
 * @returns {*}
 */
export function findOutApplyById(id) {
    return instance.get("/crm/refacoutapply/getOutApplyById", {params: {id: id}});
}

/**
 * 从残次品库中获取待返厂信息
 * @param params
 * @returns {*}
 */
export function getDefResGoods(params) {
    return instance.get("/crm/defective/getGoods", {params: params});
}

/**
 * 提交新增的出库申请单
 * @param params
 * @returns {*}
 */
export function saveNewOutApply(params) {
    return instance.post("/crm/refacoutapply/saveNewOutApply", params);
}

/**
 * 根据申请单id查询商品列表，商品来源为残次品库
 * @param id
 * @returns {*}
 */
export function findOutGoodWithApplyId(id) {
    return instance.get("/crm/refacoutgoods/getOutGoodsByApplyId", {params: {odoId: id}});
}

/**
 * 修改申请单及其对应的商品
 * @param params
 * @returns {*}
 */
export function alterOutApply(params) {
    return instance.post("/crm/refacoutapply/alterOutApply", params);
}

/**
 * 根据id批量删除申请表及其对应的商品，并修改残次品库信息
 * @param idList
 * @returns {*}
 */
export function batchDelApply(idList) {
    return instance.delete(`/crm/refacoutapply/batchDelApply/`, {data: idList});
}

/**
 * 根据id查询申请单对应的商品表
 * @param id
 * @returns {*}
 */
export function getGoodsByIdFromOutApply(id) {
    return instance.get("/crm/refacoutgoods/getGoods", {params: {odoId: id}});
}

export function approveOutApply(params) {
    return instance.post("/crm/refacoutapply/approveOutApply",params);
}